package com.jxchexie.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jxchexie.model.SignIn;
import com.jxchexie.signin.R;

import java.util.ArrayList;


/**
 * Created by zj
 */
public class SignInRecordAdapter extends RecyclerView.Adapter<SignInRecordAdapter.ListViewHolder> {


    private ArrayList<SignIn> mdatas;

    private Context mContext;

    public SignInRecordAdapter(ArrayList<SignIn> datas, Context context) {
        mdatas = datas;
        mContext = context;
    }

    @Override
    public ListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ListViewHolder holder = new ListViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_signin_record, parent, false));
        return holder;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(ListViewHolder holder, int position) {
//        holder.am_signin.setText(mdatas.get(position).getAm_signin());
//        holder.am_signout.setText(mdatas.get(position).getAm_signout());
//        holder.pm_signin.setText(mdatas.get(position).getPm_signin());
//        holder.pm_signout.setText(mdatas.get(position).getPm_signout());
//        holder.night_signin.setText(mdatas.get(position).getNight_signin());
//        holder.night_signout.setText(mdatas.get(position).getNight_signout());
//        if(mdatas.get(position).getCreate_date()!=null){
//            holder.signedDate.setText(mdatas.get(position).getCreate_date().substring(0,10));
//        }
        holder.address.setText(mdatas.get(position).getAddress());
        holder.signedDate.setText(mdatas.get(position).getDate());
        holder.signin_date.setText(mdatas.get(position).getDate()+"签到");
    }

    @Override
    public int getItemCount() {
        if(mdatas==null || mdatas.size()<=0){
            return 0;
        }
        return mdatas.size();
    }


    class ListViewHolder extends RecyclerView.ViewHolder {
        TextView address;
        TextView signedDate;
        TextView signin_date;
        public ListViewHolder(View itemView) {
            super(itemView);
            signedDate=(TextView) itemView.findViewById(R.id.signedDate);
            address=(TextView) itemView.findViewById(R.id.user_address);
            signin_date=(TextView) itemView.findViewById(R.id.signin_date);
        }
    }

}
